<<meta charset="UTF-8">
<script>
	$(function(){
		layui.use('upload', function(){
			var $ = layui.jquery
			,upload = layui.upload;
			//多图片上传
		  	upload.render({
			    elem: '#test2'
			    ,url: 'ttb/f_tk_savePicture'
			    ,multiple: true
			    ,before: function(obj){
			      	obj.preview(function(index, file, result){
			       	 	$('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
			      	});
			    }
			    ,done: function(res){
			    	var f = $("#f_picture").val();
			    	if(f != ""){
				    	f = f+","+res.msg;
			    	}else{
			    		f = res.msg;
			    	}
			    	$("#f_picture").val(f);
			    }
		  	});
		}); 

		$('#f_formButton').click(function(){
			var f_2=$("#f_2").val();
			var demo2=$("#f_picture").val();
			if(f_2==""){
				bootbox.alert("请填写请假理由！");
				return false;
			}else if(demo2==""){
				bootbox.alert("请上传佐证材料！");
				return false;
			};
			var serial=$("#f_myForm").serialize();
			$.ajax({
			    type: 'post',
			    url: 'ttb/f_tk_saveRecord',
			    data: serial,
			    success: function(data) {
			    	bootbox.alert(data.msg);
			    },error:function(data){
			    	bootbox.alert(data.msg);
			    }
			});
		});
	});
	//设置最小可选的日期
	function minDate(){
	    var now = new Date();
	    return now.getFullYear()+"-" + (now.getMonth()+1) + "-" + now.getDate();
	 }
</script>
<style type="text/css">
	.layui-upload-img {
		width: 92px;
		height: 92px;
		margin: 0 10px 10px 0;
		}
</style>
<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal"
		aria-label="Close">
		<span aria-hidden="true">&times;</span>
	</button>
	<h3 class="modal-title">停课申请</h3>
</div>
<div id="f_3">
	<form id="f_myForm">
		<input type="hidden" data-th-value="${model.ld}" name = "ld">
		<input type="hidden" data-th-value="${model.lc}" name = "lc">
		<input type="hidden" data-th-value="${model.kclbs}" name = "kclbs">
		<input type="hidden" data-th-value="${model.ydrs}" name="ydrs">
		<input type="hidden" data-th-value="${model.zxs}" name="zxs">
		<input type="hidden" data-th-value="${model.year}" name="year">
		<input type="hidden" data-th-value="${model.term}" name="term">
		<input type="hidden" data-th-value="${model.xmh}" name="xmh">
		<input type="hidden" id="f_picture" name="picture">
		<div class="input-group col-md-4"style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon ">课程名称</span> 
			<input type="text" class="form-control" name="curriculum"  readonly="readonly" data-th-value="${model.course}"/>
		</div>
		<div class="input-group col-md-4"style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon">上课班级</span> 
			<input type="text"class="form-control" name="tbClass"  readonly="readonly" data-th-value="${model.classes}" />
		</div>
		<div class="input-group col-md-4"
			style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon">星期</span> 
			<input type="text"class="form-control"name="week" readonly="readonly" data-th-value="${model.week}" />
		</div>
		<div class="input-group col-md-4"style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon">节次</span> 
			<input type="text"class="form-control"name="section"  readonly="readonly" data-th-value="${model.jc}" />
		</div>
		<div class="input-group col-md-4"
			style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon">上课地点</span> 
			<input type="text"class="form-control" name="classroom"  readonly="readonly" data-th-value="${model.classRoom}" />
		</div>
		
		<div class="input-group col-md-4"
			style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon">停课日期</span> 
			<input type="text" class="form-control" name="suspendTime" readonly="readonly" id="f_laydate" data-th-value="${model.time}" />
			<!-- <span class="glyphicon glyphicon-calendar form-control-feedback" style="margin-right: 10px;"></span> -->
		</div>	
		
		<div class="input-group col-md-12" style="padding: 0px 10px 20px 0px;">
			<span class="input-group-addon" id="sizing-addon">请假类型</span>
			<select class="form-control" name="leaveType">
				<option>公假</option>
				<option>事假</option>
				<option>病假</option>
				<option>其他</option>
			</select>
		</div>
		<div class="form-group input-group col-md-12">
			<label class="input-group-addon">请假理由</label>
		    <textarea class="form-control" rows="3" id="f_2" name="reason"></textarea>
		</div>
	
		<div class="layui-upload">
			<b>佐证材料：</b>
		  	<button type="button" class="layui-btn" id="test2">选择图片</button> 
		  	<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
		    	预览图：
		    	<div class="layui-upload-list" id="demo2"></div>
		 	</blockquote>
		</div>
	</form>
</div>
<div class="modal-footer">
	<button type="button" class="btn btn-success" data-dismiss="modal" id="f_formButton">
		<span class="glyphicon glyphicon-ok"></span> 提交申请
	</button>
	<button type="button" class="btn btn-danger" data-dismiss="modal">
		<span class="glyphicon glyphicon-remove"></span> 关闭
	</button>
</div>
